home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!cs.utexas.edu!usc!apple!sun-barr!newstop!sun!uunet.UU.NET
- From: bischeops!nick@uunet.UU.NET (Nick Bender)
- Newsgroups: comp.sources.x
- Subject: v06i089: Xchrono, Patch1, Part01/01
- Message-ID: <134815@sun.Eng.Sun.COM>
- Date: 25 Apr 90 17:17:51 GMT
- Sender: news@sun.Eng.Sun.COM
- Lines: 469
- Approved: argv@sun.com
-
- Submitted-by: bischeops!nick@uunet.UU.NET (Nick Bender)
- Posting-number: Volume 6, Issue 89
- Archive-name: xchrono/patch1
-
- Following are a few minor fixes/enhancements to xchrono:
-
- 1. A new flag/resource "dayFirst" causes dates to be displayed as day/month
- instead of month/day for international support.
-
- 2. The -local flag now works correctly when the TZ environment variable is
- not set.
-
- 3. A function SetTimezone now does the dirty work of environment munging. It
- has an ifdef HAS_SETENV intended to support systems with setenv/unsetenv
- calls, but this has not been tested because I don't have access to any such
- systems.
-
- 4. The AM/PM string in the lower left corner now has a "*" appended if the
- timezone is under daylight savings time.
-
- It has been pointed out to me that the "-L <libDirectory>" liker flag on some
- systems does not allow a space after the -L. On some systems (HPUX) the space
- is required. Since HP claims XPG2 conformance for ld, and I have no other
- source of standards, I will bow to HP. This falls under the category of
- "trivial gratuitous imcompatibily" anyway.
-
- Nuff said,
- Nick nick%bischeops@uunet.uu.net
-
- ------------------------------ snip snip snip snip ------------------------
- *** /dev/null Wed Apr 25 09:42:43 1990
- --- patchlevel.h Wed Apr 25 10:11:07 1990
- ***************
- *** 0 ****
- --- 1 ----
- + #define PATCHLEVEL 1
- diff -c2 -r xchrono.orig/MultiClock.c xchrono/MultiClock.c
- *** xchrono.orig/MultiClock.c Tue Apr 24 11:31:50 1990
- --- xchrono/MultiClock.c Tue Apr 24 12:03:31 1990
- ***************
- *** 165,168
- ClassField(updateInterval) = 60;
- ClassField(intervalId) = (XtIntervalId) 0;
- ClassField(clockList) =
- (ClockWidget *) XtMalloc(sizeof(ClockWidget)*CLOCK_LIST_SIZE);
-
- --- 165,169 -----
- ClassField(updateInterval) = 60;
- ClassField(intervalId) = (XtIntervalId) 0;
- + ClassField(dayFirst) = FALSE;
- ClassField(clockList) =
- (ClockWidget *) XtMalloc(sizeof(ClockWidget)*CLOCK_LIST_SIZE);
- ***************
- *** 211,214
- /* A public procedure for changing the update interval */
- void SetClockUpdateInterval (interval)
- {
- if (interval && interval > 0)
-
- --- 212,216 -----
- /* A public procedure for changing the update interval */
- void SetClockUpdateInterval (interval)
- + int interval;
- {
- if (interval && interval > 0)
- ***************
- *** 221,224
- }
-
- /* ARGSUSED */
- static void Initialize (request, new)
-
- --- 223,234 -----
- }
-
- + /* A public procedure for changing the month/day display order */
- + void SetClockDisplayDayFirst (dayFirstFlag)
- + Boolean dayFirstFlag;
- + {
- + ClassField (dayFirst) = dayFirstFlag;
- + updateClocks ((Widget) NULL, 0);
- + }
- +
- /* ARGSUSED */
- static void Initialize (request, new)
- ***************
- *** 385,388
- static char tzEnviron[TZ_BUFLEN+3];
-
- extern char *getenv();
-
-
- --- 395,427 -----
- static char tzEnviron[TZ_BUFLEN+3];
-
- + static void SetTimezone (zone)
- + char *zone;
- + {
- + if (zone)
- + {
- + #ifdef HAS_SETENV
- + setenv ("TZ", zone, 1);
- + #else
- + sprintf (tzEnviron, "TZ=%s", zone);
- + putenv (tzEnviron);
- + tzset ();
- + #endif /* HAS_SETENV */
- + }
- + else
- + {
- + #ifndef SYSV
- + #ifdef HAS_SETENV
- + unsetenv ("TZ");
- + #else
- + tzsetwall ();
- + #endif /* HAS_SETENV */
- + #else
- + sprintf (tzEnviron, "TZ=");
- + putenv (tzEnviron);
- + tzset ();
- + #endif /* not SYSV */
- + }
- + }
- +
- extern char *getenv();
-
- ***************
- *** 392,396
- {
- ClockWidget w = (ClockWidget) client_data;
- ! long time_value;
- char localTimezone[TZ_BUFLEN];
- char *tzenv = getenv("TZ");
-
- --- 431,436 -----
- {
- ClockWidget w = (ClockWidget) client_data;
- ! struct timeval time_value;
- ! struct timezone time_zone;
- char localTimezone[TZ_BUFLEN];
- char *tzenv = getenv("TZ");
- ***************
- *** 405,409
- XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) *list),
- ClassField(updateInterval)*1000, updateClocks, NULL );
- ! (void) time(&time_value);
- if (tzenv) strcpy (localTimezone, tzenv);
-
-
- --- 445,449 -----
- XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) *list),
- ClassField(updateInterval)*1000, updateClocks, NULL );
- ! gettimeofday (&time_value, &time_zone);
- if (tzenv) strcpy (localTimezone, tzenv);
-
- ***************
- *** 416,419
- while (count--)
- {
- (*list)->clock.show_second_hand =
- (ClassField(updateInterval) <= SECOND_HAND_TIME);
-
- --- 456,461 -----
- while (count--)
- {
- + char *thisZone = (*list)->clock.timezone;
- +
- (*list)->clock.show_second_hand =
- (ClassField(updateInterval) <= SECOND_HAND_TIME);
- ***************
- *** 420,431
- if (XtIsRealized(*list))
- {
- ! if ((*list)->clock.timezone)
- ! {
- ! sprintf (tzEnviron, "TZ=%s", (*list)->clock.timezone);
- ! putenv (tzEnviron);
- ! tzset ();
- ! }
- ! tm = *localtime(&time_value);
- ! clock_tic (*list, tm);
- list++;
- }
-
- --- 462,473 -----
- if (XtIsRealized(*list))
- {
- ! Boolean isDST;
- !
- ! SetTimezone (thisZone);
- ! tm = *localtime(&time_value.tv_sec);
- ! if (thisZone) isDST = tm.tm_isdst;
- ! else isDST = time_zone.tz_dsttime;
- !
- ! clock_tic (*list, tm, isDST);
- list++;
- }
- ***************
- *** 432,443
- }
-
- ! if (tzenv)
- ! {
- ! sprintf (tzEnviron, "TZ=%s", localTimezone);
- ! putenv (tzEnviron);
- ! }
- ! #ifndef SYSV
- ! else tzsetwall();
- ! #endif /* not SYSV */
- }
-
-
- --- 474,478 -----
- }
-
- ! SetTimezone (tzenv);
- }
-
- ***************
- *** 444,448
-
- /* ARGSUSED */
- ! static void clock_tic(w, tm)
- ClockWidget w;
- struct tm tm;
-
- --- 479,483 -----
-
- /* ARGSUSED */
- ! static void clock_tic(w, tm, isdst)
- ClockWidget w;
- struct tm tm;
- ***************
- *** 446,450
- static void clock_tic(w, tm)
- ClockWidget w;
- ! struct tm tm;
- {
- char time_string[28];
-
- --- 481,486 -----
- static void clock_tic(w, tm, isdst)
- ClockWidget w;
- ! struct tm tm;
- ! int isdst;
- {
- char time_string[28];
- ***************
- *** 522,526
- if (tm.tm_hour > 12)
- tm.tm_hour -= 12;
- ! am_pm = "PM";
- }
- else am_pm = "AM";
-
- --- 558,562 -----
- if (tm.tm_hour > 12)
- tm.tm_hour -= 12;
- ! am_pm = (isdst ? "PM*" : "PM");
- }
- else am_pm = (isdst ? "AM*" : "PM");
- ***************
- *** 524,528
- am_pm = "PM";
- }
- ! else am_pm = "AM";
-
- sprintf (time_string, "%d/%d", tm.tm_mon+1, tm.tm_mday);
-
- --- 560,564 -----
- am_pm = (isdst ? "PM*" : "PM");
- }
- ! else am_pm = (isdst ? "AM*" : "PM");
-
- if (ClassField(dayFirst))
- ***************
- *** 526,530
- else am_pm = "AM";
-
- ! sprintf (time_string, "%d/%d", tm.tm_mon+1, tm.tm_mday);
- {
- int len = strlen (time_string);
-
- --- 562,570 -----
- else am_pm = (isdst ? "AM*" : "PM");
-
- ! if (ClassField(dayFirst))
- ! sprintf (time_string, "%d/%d", tm.tm_mday, tm.tm_mon+1);
- ! else
- ! sprintf (time_string, "%d/%d", tm.tm_mon+1, tm.tm_mday);
- !
- {
- int len = strlen (time_string);
- diff -c2 -r xchrono.orig/MultiClock.h xchrono/MultiClock.h
- *** xchrono.orig/MultiClock.h Tue Apr 24 11:31:52 1990
- --- xchrono/MultiClock.h Mon Apr 23 09:24:42 1990
- ***************
- *** 91,94
- extern void SetClockUpdateInterval(/* int interval */);
-
- #endif /* _XawClock_h */
- /* DON'T ADD STUFF AFTER THIS #endif */
-
- --- 91,96 -----
- extern void SetClockUpdateInterval(/* int interval */);
-
- + extern void SetClockDisplayDayFirst(/* Boolean flag */);
- +
- #endif /* _XawClock_h */
- /* DON'T ADD STUFF AFTER THIS #endif */
- diff -c2 -r xchrono.orig/MultiClockP.h xchrono/MultiClockP.h
- *** xchrono.orig/MultiClockP.h Tue Apr 24 11:31:54 1990
- --- xchrono/MultiClockP.h Mon Apr 23 09:24:36 1990
- ***************
- *** 87,90
- typedef struct {
- int updateInterval;
- XtIntervalId intervalId;
- ClockWidget *clockList;
-
- --- 87,91 -----
- typedef struct {
- int updateInterval;
- + Boolean dayFirst;
- XtIntervalId intervalId;
- ClockWidget *clockList;
- diff -c2 -r xchrono.orig/README xchrono/README
- *** xchrono.orig/README Tue Apr 24 11:31:41 1990
- --- xchrono/README Tue Apr 24 12:18:31 1990
- ***************
- *** 16,20
- [-rv] [-update <seconds>] [-display displayname]
- [-geometry geom]
- ! [-width clockWidth] [-height clockHeight] [-local localName]
- [-boston] [-newyork] [-chicago] [-denver] [-la]
- [-hawaii] [-tokyo] [-sydney] [-london]
-
- --- 16,21 -----
- [-rv] [-update <seconds>] [-display displayname]
- [-geometry geom]
- ! [-width clockWidth] [-height clockHeight]
- ! [-dayFirst] [-local localName]
- [-boston] [-newyork] [-chicago] [-denver] [-la]
- [-hawaii] [-tokyo] [-sydney] [-london]
- ***************
- *** 24,28
- are taken from tztab in the SYSV case, and from /usr/lib/zoneinfo
- otherwise, and as such may or may not be correct (the TZ variable
- ! definitions or the city->timezone mappings).
-
- The -local <localName> option causes a clock labeled with <localName>
-
- --- 25,32 -----
- are taken from tztab in the SYSV case, and from /usr/lib/zoneinfo
- otherwise, and as such may or may not be correct (the TZ variable
- ! definitions or the city->timezone mappings). The AM/PM string in the lower
- ! left corner will have an asterisk ("AM*") if the timezone is currently
- ! under daylight savings time. The date string in the lower right is by
- ! default in month/day format, but can be switched by the -dayFirst flag.
-
- The -local <localName> option causes a clock labeled with <localName>
- ***************
- *** 74,77
- -----------
-
- % set topDir = <where you installed X> ## default is /
- % $topDir/usr/bin/X11/imake -I$topDir/usr/lib/X11/config
-
- --- 78,85 -----
- -----------
-
- + If your systems supports setenv and unsetenv (4.3BSD-tahoe or other) figure out
- + how to get HAS_SETENV defined in MultiClock.c (add it to MultiClock.c or figure
- + the right thing to do with imake :-).
- +
- % set topDir = <where you installed X> ## default is /
- % $topDir/usr/bin/X11/imake -I$topDir/usr/lib/X11/config
- ***************
- *** 77,81
- % $topDir/usr/bin/X11/imake -I$topDir/usr/lib/X11/config
- % make
- -
-
-
-
- --- 85,88 -----
- % $topDir/usr/bin/X11/imake -I$topDir/usr/lib/X11/config
- % make
-
-
- diff -c2 -r xchrono.orig/xchrono.c xchrono/xchrono.c
- *** xchrono.orig/xchrono.c Tue Apr 24 11:31:43 1990
- --- xchrono/xchrono.c Mon Apr 23 09:23:59 1990
- ***************
- *** 111,114
- int clockHeight;
- String localName;
- Boolean boston;
- Boolean newyork;
-
- --- 111,115 -----
- int clockHeight;
- String localName;
- + Boolean dayFirst;
- Boolean boston;
- Boolean newyork;
- ***************
- *** 136,139
- {"localName", "LocalName", XtRString, sizeof (String),
- offset(localName), XtRString, "" },
- {"boston", "Boston", XtRBoolean, sizeof(Boolean),
- offset(boston), XtRString, "false" },
-
- --- 137,142 -----
- {"localName", "LocalName", XtRString, sizeof (String),
- offset(localName), XtRString, "" },
- + {"dayFirst", "DayFirst", XtRBoolean, sizeof(Boolean),
- + offset(dayFirst), XtRString, "false" },
- {"boston", "Boston", XtRBoolean, sizeof(Boolean),
- offset(boston), XtRString, "false" },
- ***************
- *** 180,183
- {"-height", "*clockHeight", XrmoptionSepArg, NULL},
- {"-local", "*localName", XrmoptionSepArg, NULL},
- {"-boston", "*boston", XrmoptionNoArg, "on"},
- {"-newyork", "*newyork", XrmoptionNoArg, "on"},
-
- --- 183,187 -----
- {"-height", "*clockHeight", XrmoptionSepArg, NULL},
- {"-local", "*localName", XrmoptionSepArg, NULL},
- + {"-dayFirst", "*dayFirst", XrmoptionNoArg, "on"},
- {"-boston", "*boston", XrmoptionNoArg, "on"},
- {"-newyork", "*newyork", XrmoptionNoArg, "on"},
- ***************
- *** 213,217
- (void) printf (" [-rv] [-update <seconds>] [-display displayname]\n");
- (void) printf (" [-geometry geom]\n");
- ! (void) printf (" [-width clockWidth] [-height clockHeight] [-local localName]\n");
- (void) printf (" [-boston] [-newyork] [-chicago] [-denver] [-la]\n");
- (void) printf (" [-hawaii] [-tokyo] [-sydney] [-london]\n");
-
- --- 217,222 -----
- (void) printf (" [-rv] [-update <seconds>] [-display displayname]\n");
- (void) printf (" [-geometry geom]\n");
- ! (void) printf (" [-width clockWidth] [-height clockHeight]\n");
- ! (void) printf (" [-dayFirst] [-local localName]\n");
- (void) printf (" [-boston] [-newyork] [-chicago] [-denver] [-la]\n");
- (void) printf (" [-hawaii] [-tokyo] [-sydney] [-london]\n");
- ***************
- *** 392,395
-
- SetClockUpdateInterval (resource.updateInterval);
- XtRealizeWidget (toplevel);
-
-
- --- 397,401 -----
-
- SetClockUpdateInterval (resource.updateInterval);
- + if (resource.dayFirst) SetClockDisplayDayFirst (TRUE);
- XtRealizeWidget (toplevel);
-
-
- dan
- -----------------------------------------------------------
- O'Reilly && Associates
- argv@sun.com / argv@ora.com
- 632 Petaluma Ave, Sebastopol, CA 95472
- 800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
- Opinions expressed reflect those of the author only.
-